﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Agr.CQRS.Infrastructure.ServiceBus;

namespace Tests.Agr.CQRS.SB
{
    [TestClass]
    public class When_Event_Is_Published_Transactional_On_ServiceBus
    {
        [TestInitialize]
        public void TestInit()
        {
            //Given
            var sb = new ServiceBus();
            sb.Subscribe<someSortOfEvent>(handleEvent);
            var tx = sb.OpenTransaction();

            //When
            sb.PublishTransactional(tx, new someSortOfEvent());

            tx.Rollback();
        }

        [TestMethod()]
		public void Then_No_EventHandlers_Are_Called()
		{
            Assert.IsFalse(handled);
		}

        private bool handled;
        private void handleEvent(someSortOfEvent ev) { handled = true; }

        private class someSortOfEvent { }
    }
}
